import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

Vue.config.productionTip = false

import {
  Form, FormItem, Input, Button, Select, Option, Message, Container,
  Header,
  Aside,
  Main,
  Menu,
  MenuItem,
  Table,
  TableColumn,
  Drawer,
  DatePicker,
  Pagination,
  Link,
  Upload,
  Tabs,
  TabPane
} from 'element-ui'

Vue.use(Form);
Vue.use(FormItem);
Vue.use(Input);
Vue.use(Button);
Vue.use(Select);
Vue.use(Option);
Vue.use(Container);
Vue.use(Header);
Vue.use(Aside);
Vue.use(Main);
Vue.use(Menu);
Vue.use(MenuItem);
Vue.use(Table);
Vue.use(TableColumn);
Vue.use(Drawer);
Vue.use(DatePicker);
Vue.use(Pagination);
Vue.use(Link);
Vue.use(Upload);
Vue.use( Tabs );
Vue.use( TabPane );
Vue.prototype.$message = Message;



//过滤路由表，过滤并生成该用户有权限访问的路由
//将最终生成的 该用户有权限访问的路由，动态添加到公共路由表中
if( store.state.userinfo && store.state.userinfo.role.permissions ){
  router.addRoutes( store.getters.getRoutes );
}

new Vue({
  router,
  store, //将store对象挂载到根实例上, 在所有组件中都可以通过 this.$store 获取store对象, 进而可以获取store对象身上 的 commit() dispatch()  getters , state

  render: h => h(App)
}).$mount('#app')
